
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>后台首页</title>
    <link type="text/css" rel="stylesheet" href="./css/base.css" />
    <link type="text/css" rel="stylesheet" href="./css/top.css" />
    <link type="text/css" rel="stylesheet" href="./css/left.css" />
    <link type="text/css" rel="stylesheet" href="./css/right.css" />
    <script src="admin/jquery/jquery.min.js"></script>
</head>
<body>
<div id="cont">
    <div id="top">
        <div id="top_a">
            <h1>博客管理系统</h1>
        </div>
        <div id="top_b">欢迎你: <?php echo session("admin_name")?><a href="index.php?s=admin/category/quit">推出登录</a></div>
    </div>
    <div id="left">
        <ul>
            <li><a href="index.php?c=Category&a=categorys">分类列表</a></li>
            <li><a href="/index.php?s=admin/article/article_list">文章列表</a></li>
            <li><a href="index.php?c=Admin&a=admins">管理员</a></li>
        </ul>
    </div>
    <div id="right">
        <div id="right_a">
            <a href="#">首页</a>&gt;
            <a href="/index.php?s=admin/article/article_list">文章列表</a>&gt;
            <a href="index.php?s=admin/category/category_list">分类列表</a>
        </div>
        <div id="right_b">
            筛选：<select id="select">
                <option value="1" >正常</option>
                <option value="2"<?php echo  $rubbush == 2 ?'selected="selected"' : '' ?>>回收站</option>
            </select>
            <button id="button">搜索</button>
        </div>
        <div id="right_c">
            <form id="form_base" action="index.php?c=Category&a=delete_save" method="post">
                <table border="">
                    <tr>
                        <th></th>
                        <th>ID</th>
                        <th>评论昵称</th>
                        <th>邮箱</th>
                        <th>评论内容</th>
                        <th>评论时间</th>
                        <th>修改时间</th>
                        <th>操作</th>
                    </tr>
                    <?php foreach($commentList as $row) : ?>
                        <tr>
                            <td><input type="checkbox" class="checkbox" name="checkbox[]"  value="<?php echo $row["category_id"]; ?>"></td>
                            <td><?php echo $row["comment_id"]; ?></td>
                            <td><?php echo $row["nickname"]; ?></td>
                            <td><?php echo $row["email"]; ?></td>
                            <td><?php echo $row["comment_content"]; ?></td>
                            <td><?php echo date("Y-m-d H:i:s",$row["add_time"]) ; ?></td>
                            <td><?php echo date("Y-m-d H:i:s",$row["update_time"]) ; ?></td>
                            <td>
                                <?php if($row['rubbush'] == 1): ?>
                                    <a class = 'rubbush' href='/index.php?s=admin/comment/rubbush/comment_id/<?php echo $row['comment_id']?>'>移入回收站</a>
                                <?php endif; ?>

                                <?php if($row['rubbush'] == 2): ?>
                                <a class = 'recovery' href='/index.php?s=admin/comment/recovery/comment_id/<?php echo $row['comment_id']?>'>恢复</a>
                                    <a class="delete" href='/index.php?s=admin/comment/delete/comment_id/<?php echo $row['comment_id']?>'>彻底删除</a>
                                <?php endif; ?>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </table>
<!--                <div id="render">-->
<!--                    --><?php //echo $cateforyList->render();?>
<!--                </div>-->

            </form>
        </div>
    </div>
</div>
<script>
    $('#button').click(function(){
        let val = $('#select').val();
        console.log(val);
        window.location.href = '/index.php?s=admin/comment/comment_list'+'/rubbush/'+val;
    });
    //移入回收站
    $('.rubbush').click(function (){
        let href = $(this).attr('href');
        let _this = $(this);
        $.ajax({
            url:href,
            type:'GET',
            data:{},
            success:function (value) {
                console.log(value);
                if(value.status === 0){
                    window.alert(value.message);
                    _this.parent().parent().remove();
                }else{
                    window.alert(value.message);
                }
            }
        });
        return false;
    });
    //恢复
    $('.recovery').click(function(){
        let href = $(this).attr('href');
        console.log(href);
        let _this=$(this);
        $.ajax({
            url:href,
            type:'GET',
            data: {},
            success:function (value) {
                // console.log(value);
                if(value.status === 0){
                    window.alert(value.message);
                    _this.parent().parent().remove();
                }else{
                    window.alert(value.message);
                }
            }
        }
        );
        return false;
    });
    //彻底删除
    $('.delete').click(function (){
        let href = $(this).attr('href');
        console.log(href);
        let _this = $(this);
        console.log(_this);
        $.ajax({
                url:href,
                type:'GET',
                data: {},
                success:function (value) {
                    console.log(value);
                    if(value.status === 0){
                        window.alert(value.message);
                        _this.parent().parent().remove();
                    }else{
                        window.alert(value.message);
                    }
                }
            }
        );
        return false;
    });
</script>
</html>
</body>

